import itertools
            
# Name = ["Mike","Ellie","Rohan","Fatma"]
# Color = ["red","blue","purple","green"]
#for item in itertools.product(Name):
    #print(item)
Name = list(itertools.permutations(['Mike', 'Ellie', 'Rohan', 'Fatma'], 4))
print("1111111111111111111111111111")
#print(Name)
Color= list(itertools.permutations(["red","blue","purple","green"], 4))
print("22222222222222222222222222222")
#print(Color)
Name_list=[]
for item in Name:
    if(item[0]!='Mike' and item[3]!='Mike' and item[0]!='Ellie'and item[3]!='Ellie'):
        Name_list.append(item)
print("33333333333333333333333333333")
#print(Name_list)
for name in Name_list:
    for color in Color:
        list = [name,color]
        #print(list[0][1])
        color_index0 = list[1].index("purple")  #Ellie骑紫色车
        if(list[0][color_index0]!='Ellie'):
            continue
        color_index1 = list[1].index("green") #Rohan不骑绿色车
        if(list[0][color_index1]=='Rohan'):
            continue
        color_index2 = list[1].index("blue")
        name_index0 = list[0].index('Fatma')
        if(color_index2 >= name_index0):     #骑蓝色车比F快
            continue
        color_index3 = list[1].index("green")
        color_index4 = list[1].index("purple")
        if(color_index3 >= color_index4):     #骑蓝色车比F快
            continue
        print(list)
        print("第二名为")
        print(list[0][1])
